#ifndef __VLOG_LOG_EVENT_H__
#define __VLOG_LOG_EVENT_H__

#include "loglevel.h"
#include <memory>
#include <optional>
#include <sstream>
#include <stdint.h>

namespace vlog
{
class Logger;

namespace event
{

/// @brief 日志事件内容
class LogEvent
{
    public:
    using ptr = std::shared_ptr<LogEvent>;

    LogEvent() = delete;

    ~LogEvent() = default;

    LogEvent(const char* fileName, const LogLevel::Level level, uint32_t fileLine, uint64_t runTimeMs,
             uint64_t curTimeMs, uint64_t curThreadId, const std::string& curThreadName = "",
             const std::string& curFunctionName = "", const std::string& loggerName = "");

    const char* GetEventFileName() const noexcept
    {
        return m_FileName;
    }
    uint32_t GetEventFileLine() const noexcept
    {
        return m_FileLine;
    }
    uint64_t GetEventRunTime() const noexcept
    {
        return m_RunTimeMs;
    }
    uint64_t GetEventTime() const noexcept
    {
        return m_CurTimeMs;
    }
    uint64_t GetEventThreadID() const noexcept
    {
        return m_CurThreadId;
    }
    const std::string& GetEventThreadName() const noexcept
    {
        return m_CurThreadName;
    }
    const std::string& GetEventFuncName() const noexcept
    {
        return m_CurFunctionName;
    }

    const std::string GetEventMessageText() const noexcept
    {
        return m_ssLogMessage.str();
    }
    std::stringstream& GetEventMessageSS() noexcept
    {
        return m_ssLogMessage;
    }

    LogLevel::Level GetEventLogLevel() const noexcept
    {
        return m_Level;
    }

    const std::string& GetEventLoggerName() const noexcept
    {
        return m_LoggerName;
    }

    private:
    const char* m_FileName = nullptr;                  // 文件名
    uint32_t m_FileLine = 0;                           // 文件行数
    uint64_t m_RunTimeMs = 0;                          // 运行时间MS
    uint64_t m_CurTimeMs = 0;                          // 时间
    uint64_t m_CurThreadId = 0;                        // 线程id
    std::string m_CurThreadName = "";                  // 当前线程名称
    std::string m_CurFunctionName = "";                // 函数名称
    std::stringstream m_ssLogMessage;                  // Message 内容流
    LogLevel::Level m_Level = LogLevel::Level::UNKONW; // 当前事件的等级
    std::string m_LoggerName;
};

} // namespace event

} // namespace vlog

#endif